<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create an IntlCalendar from a DateTime object or string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intlcalendar.fielddifference.html">IntlCalendar::fieldDifference</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.get.html">IntlCalendar::get</a></div>
 <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intlcalendar.fromdatetime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlCalendar::fromDateTime</h1>
  <p class="verinfo">(PHP 5.5.0, PECL &gt;= 3.0.0a2)</p><p class="refpurpose"><span class="refname">IntlCalendar::fromDateTime</span> &mdash; <span class="dc-title">Create an IntlCalendar from a DateTime object or string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlcalendar.fromdatetime-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <span class="methodname"><strong>IntlCalendar::fromDateTime</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$dateTime</code></span>
   )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <span class="methodname"><strong>intlcal_from_date_time</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$dateTime</code></span>
   )</div>

  <p class="para rdfs-comment">
   Creates an <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> object either from a
   <a href="class.datetime.html" class="classname">DateTime</a> object or from a string from which a
   <a href="class.datetime.html" class="classname">DateTime</a> object can be built.
  </p>
  <p class="para">
   The new calendar will represent not only the same instant as the
   given <a href="class.datetime.html" class="classname">DateTime</a> (subject to precision loss for dates
   very far into the past or future), but also the same timezone (subject to
   the caveat that different timezone databases will be used, and therefore
   the results may differ).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlcalendar.fromdatetime-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">dateTime</code></em></dt>

    <dd>

     <p class="para">
      A <a href="class.datetime.html" class="classname">DateTime</a> object or a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> that
      can be passed to <span class="function"><a href="datetime.construct.html" class="function">DateTime::__construct()</a></span>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlcalendar.fromdatetime-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The created <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> object or <strong><code>NULL</code></strong> in case of
   failure. If a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> is passed, any exception that occurs
   inside the <a href="class.datetime.html" class="classname">DateTime</a> constructor is propagated.
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-intlcalendar.fromdatetime-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2532">
   <p><strong>Example #1 <span class="function"><strong>IntlCalendar::fromDateTime()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//same&nbsp;as&nbsp;IntlCalendar::fromDateTime(new&nbsp;DateTime(...))<br /></span><span style="color: #0000BB">$cal1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">fromDateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">'2013-02-28&nbsp;00:01:02&nbsp;Europe/Berlin'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//Note&nbsp;the&nbsp;timezone&nbsp;is&nbsp;Europe/Berlin,&nbsp;not&nbsp;the&nbsp;default&nbsp;Europe/Lisbon<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'yyyy&nbsp;MMMM&nbsp;d&nbsp;HH:mm:ss&nbsp;VVVV'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
2013 Februar 28 00:01:02 Deutschland Zeit
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intlcalendar.fielddifference.html">IntlCalendar::fieldDifference</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.get.html">IntlCalendar::get</a></div>
 <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
